package com.kgc.sportscircle.impl;

import com.kgc.sportscircle.pojo.Mallproductdetail;
import com.kgc.sportscircle.dao.MallproductdetailMapper;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import com.kgc.sportscircle.utils.Page;
import javax.annotation.Resource;
import com.kgc.sportscircle.vo.MallproductdetailParam;
import com.alibaba.dubbo.config.annotation.Service;
import com.kgc.sportscircle.service.MallproductdetailService;
/**
* 描述： 服务实现层接口
* @author 杨海文
* @date 2019/07/22
*/
@Service(timeout = 50000,retries = 2,version = "1.11",interfaceClass=MallproductdetailService.class)
public class MallproductdetailServiceImpl implements MallproductdetailService{
	@Resource
	private MallproductdetailMapper mallproductdetailMapper;
 	
 	/**
    * 描述：根据Id获取Mallproductdetail对象
    * @param id
    */
    public Mallproductdetail findById(Serializable id){
    	return mallproductdetailMapper.findById(id);
    }
    /**
    * 描述：获取所有的Mallproductdetail对象
    */
    public List<Mallproductdetail> findAll(){
    	return mallproductdetailMapper.findAll();
    }

	/**
    * 描述：新增保存Mallproductdetail对象
    */
    public int save(Mallproductdetail mallproductdetail){
    	return  mallproductdetailMapper.save(mallproductdetail);
    }

	/**
    * 描述：根据Id删除Mallproductdetail对象
    * @param id
    */
    public int delete(Serializable id){
    	return  mallproductdetailMapper.delete(id);
    }
	
	/**
    * 描述：更新Mallproductdetail对象
    */
    public int update(Mallproductdetail mallproductdetail){
    	return  mallproductdetailMapper.update(mallproductdetail);
    }
    
    /**
     * 根据不确定的条件，动态查询
     */
    public List<Mallproductdetail> query(MallproductdetailParam param){
    	return  mallproductdetailMapper.query(param);
    }
    
    /**
     * 根据不确定的条件，动态分页查询
     */
    public Page queryByPage(MallproductdetailParam param){
    	Page page = new Page();
    	if(param.isPage()){
			int totalCount = mallproductdetailMapper.getCount(param);
			int totalPageCount = (totalCount-1)/page.getPageSize()+1;
			if(param.getPageIndex()<1){
				param.setPageIndex(1);
			}else if(param.getPageIndex()>totalPageCount){
				param.setPageIndex(totalPageCount);
			}
			List list = mallproductdetailMapper.query(param);

			page.setTotalCount(totalCount);
			page.setTotalPageCount(totalPageCount);
    		page.setPageNo(param.getPageIndex());
    		page.setPageSize(param.getSize());
			page.setList(list);
		}
    	return page;
    	
    }

}
